	var setDateFlag = 0;//设定标志
	var myDate = new Date();
	var year = myDate.getFullYear();
	var month = myDate.getMonth();
	var day = myDate.getDate();
	var nowDate2 = year + "年" + (month+1) + "月" + day + "日";
	var arrayShowDates = [];//当前显示数组
	var calendarDate = [];
	var show = 0;
$(function(){
	//默认显示日期
    $("#courseDateShow").html(nowDate2);
    var time=getNowFormatDate(myDate);
    // 初始化日历
    $("#courseDate_input").calendar({
    	dateFormat: 'yyyy-mm-dd',
    	onClose: function () {
            //$("#courseDate_input").calendar("destroy");
        },
        //点击日历选择时间
	     onChange: function (p, values, displayValues) {
	        	//console.log(values.toString())
	        if (setDateFlag==0) {
                alert(2);
	            arrayShowDates = [];
                var nowDate2 = values.toString().split("-")[0] + "年" + values.toString().split("-")[1] + "月" + values.toString().split("-")[2] + "日";
	        }
	    },
        onOpen: function () {
            alert(1);
        	if (setDateFlag == 1) {
        		$("#courseDate_input").calendar("setValue", calendarDate);
        		setDateFlag = 0
        	}
        }

    });
   
})

//获取当前时间，格式YYYY-MM-DD
function getNowFormatDate(dates) {
    var date = new Date(dates);
    var seperator1 = "-";
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = year + seperator1 + month + seperator1 + strDate;
    return currentdate;
    //console.log(currentdate)
}


